import { virSearch } from "@/api/view/pages/generate_api";
import { Button } from "@/components/ui/btn/button1";
import { LabelInput } from "@/components/ui/input/label_input";
import { Search } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";

export default function GenerateBtnTop({
  searchBatch,
  selectedType,
  setOptions,
}: {
  searchBatch: string;
  selectedType: string;
  setOptions: React.Dispatch<React.SetStateAction<GenerateRowProps[]>>;
}) {
  const [id, setID] = useState("");

  const dotask = async () => {
    try {
      console.log("searchBatch", searchBatch);
      console.log("selectedType", selectedType);
      setOptions(virSearch);
      toast.success("模拟了查询！", { position: "top-center" });
    } catch (error) {
      console.log(error);
      toast.error("笔记数据获取异常！", {
        duration: 10000,
        position: "top-center",
      });
    }
  };

  return (
    <div className="flex h-[50px] w-full flex-col">
      <div className="flex h-auto w-full flex-row justify-start space-x-4">
        <LabelInput
          label="ID"
          value={id}
          onChange={(e) => {
            setID(e.target.value);
          }}
          type="text"
          placeholder="请输入ID"
          labelPosition="left"
        />
        <Button
          size="icon"
          variant="default"
          className="rounded-full"
          onClick={dotask}
        >
          <Search className="h-4 w-4" />
        </Button>
      </div>
    </div>
  );
}
